<?php
/**
 * Created by PhpStorm.
 * User: qttx
 * Date: 2019/5/30
 * Time: 13:58
 */
namespace app\api\model;

class ComplaintModel extends BaseModel
{
    protected $table = "xst_complaint";
    protected $rule = [
        'id' => '',
    ];
    protected $msg = [
        'id' => '',
    ];
  
    /**添加**/
    public function complaint_add($add)
    {
        $complaint_add = $this->insert(
			[
			   'type'=>$add['type'],
			   'photo'=>$add['photo'],
			   'content'=>$add['content'],
			   'createtime'=>time(),
			]);
        return $complaint_add;
    }

	/**投诉截图添加**/
	//接值：返回的id，图片
	//返回图片的路径
	 public function photo_add($photo)
    {
        $filename=md5(time().rand(1,1000));
        $fileRoute = ROOT_PATH . '/upload/complaint/'; 
        $info = $photo->move($fileRoute,$filename);
        if ($info){
           $photo = '/upload/complaint/'.$info->getFilename().',';
        }else{
            // 上传失败获取错误信息
            return $file->getError();
        }
		return $photo;
     }
}